#设计一个account银行账户类，有三个变量：amount账户金额，interest_rate利率，owner账户名，
#amount和owner对每个账户都是不同的，interest_rate对于所有账户都相同，设计显示账户信息的方法，和传入金额计算利息的方法
class Account(object):
    interest_rate = 0.0568 #类数据


    def __init__(self,owner,amount): #对象数据
        self.owner = owner
        self.amount = amount

    def show_owner_info(self): #对象方法
        print(f'账户名：{self.owner} 存款额：{self.amount}')

    @classmethod #类方法：传入一个金额计算利息
    def interest_by(cls,money):
        return money *cls.interest_rate

if __name__ == '__main__':
    interest = Account.interest_by(10000)
    print(f'interest = {interest}')

    account1 = Account('张三',999)
    account1.show_owner_info()

#合并两个字典中相同键的值，如果两个字典都有同一个键，则将值相加。
dict_a = {'a': 100, 'b': 200, 'c': 300}
dict_b = {'a': 200, 'b': 150, 'd': 400}

# 输出: merge_dict_sum = {'a': 300, 'b': 350, 'c': 300, 'd': 400}

merge_dict_sum = {}
# merge_list = [dict_a,dict_b]
# # def merge_dic():
# for i in merge_list:
for j in dict_a.keys():
    for i in dict_b.keys():
        if j in dict_b.keys():
            # 1、如果健放进去，值相加
            current_values = dict_a[j]
            merge_dict_sum[j] = current_values + dict_b[j]
            # merge_dict_sum[j] = dict_a[j] + dict_b[j]



        else:
        # 2、健没有放进去，则为当前值
             merge_dict_sum[j] = dict_a[j]
             if i not in dict_a.keys():
                merge_dict_sum[i] = dict_b[i]

print(merge_dict_sum)


